package com.yjd.pub.app.service;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.yjd.comm.base.enums.DbWREnums;
import org.springframework.stereotype.Service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.app.model.PushRecordModel;
import com.yjd.comm.app.service.IPushRecordService;
import com.yjd.pub.app.dao.IPushRecordDao;

/**
 * <b>description</b>：推送消息记录业务实现<br>
 * <b>time</b>：2017-08-11 17:30:25 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("pushRecordService")
public class PushRecordServiceImpl extends BaseServiceImpl implements IPushRecordService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public PushRecordModel insert(PushRecordModel model) throws Exception {
		return this.pushRecordDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(PushRecordModel model) throws Exception {
		return this.pushRecordDao.updateModel(model, true);
	}

	@Override
	public int updateByMap(Map paramMap, DbWREnums write) throws Exception {
		return this.pushRecordDao.updateByMap(paramMap, write.isWrite());
	}

	/**
	 * 根据id删除
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int delete(long id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id", id);
		return this.pushRecordDao.deleteModel(paramMap, true);
	}

	@Resource
	private IPushRecordDao pushRecordDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.pushRecordDao;
	}

}
